package com.outdoor.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.outdoor.model.enums.ApplicationStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;

/**
 * 申请实体类
 * 
 * @author OutdoorTeam
 * @date 2025-05-18
 */
@Data
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("applications")
public class Application extends BaseEntity {
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    /**
     * 申请用户ID
     */
    private Long userId;
    
    /**
     * 申请团队ID
     */
    private Long teamId;
    
    private String experience;
    private String message;
    
    /**
     * 申请状态，存储为字符串
     */
    @TableField("status")
    private String statusStr;
    
    @TableField(exist = false)
    private ApplicationStatus status;
    
    private LocalDateTime applyTime;
    
    public ApplicationStatus getStatus() {
        if (statusStr == null) {
            return null;
        }
        return ApplicationStatus.valueOf(statusStr);
    }
    
    public void setStatus(ApplicationStatus status) {
        this.status = status;
        if (status != null) {
            this.statusStr = status.name();
        }
    }
} 